package nio.filechannel;

import java.io.*;
import java.nio.channels.FileChannel;

public class NIOFileChannel4 {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\java-ee\\java-ee\\netty\\src\\pic1.jpg");
        FileInputStream fileInputStream = new FileInputStream(file);
        FileChannel srcChannel = fileInputStream.getChannel();
        FileOutputStream fileOutputStream = new FileOutputStream("D:\\java-ee\\java-ee\\netty\\src\\pic2.jpg");
        FileChannel targetChannel = fileOutputStream.getChannel();
        targetChannel.transferFrom(srcChannel, 0, file.length());
        srcChannel.close();
        targetChannel.close();
        fileInputStream.close();
        fileOutputStream.close();
    }
}
